//
//  type_name_stack.c
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//
#include <stdlib.h>
#include <stdio.h>
#include "type_name_stack.h"
#include "defines.h"

struct type_name_stack{
	enum type stack[32]; //last argument = first in this array
	int _count; //number of []
};

struct type_name_stack instance;

void type_name_stack_init(){
	instance._count = 0;
}
void type_name_stack_push(enum type type){
	instance.stack[instance._count]=type;
	instance._count++;
}
enum type type_name_stack_head(){
	return instance.stack[instance._count-1];
}
enum type type_name_stack_pop(){
	enum type t = type_name_stack_head();
	instance._count--;
	return t;
}

void type_name_stack_print(){
	printf("print stack\n");
	printf(" > number of elements : %d\n", instance._count);
	printf("head to tail\n");
	int i=instance._count-1;
	for(; i > -1; i--){
		printf("element i %s\n",instance.stack[i] == TYPE_VOID ? "void" :
					 (instance.stack[i] == TYPE_FLOAT ? "float" : "int"));
	}
}